//
//  HDEditPassWordCell.swift
//  HuaDaoPeifu
//
//  Created by liangyuanliangyuan on 16/4/20.
//  Copyright © 2016年 paiyipai. All rights reserved.
//  修改密码界面的cell

import UIKit
enum twoCellType {
    case editPW,forgetPW
}

protocol HDForgetPWDelegate :class {
    func getVertifDelegate()
}

class HDEditPassWordCell: UITableViewCell ,UITextFieldDelegate{

    
    var leftTitle = UILabel()
    var inputTextField = UITextField()
    var line1 = UILabel()
    var line2 = UILabel()
    var getVerifiButton = UIButton()
    var cellType:twoCellType?
    var delegate:HDForgetPWDelegate?
    
    
     init(style: UITableViewCellStyle, reuseIdentifier: String?,cellType:twoCellType) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.backgroundColor = UIColor.white
        
        leftTitle = UILabel()
        leftTitle.textColor = UIColor(hex: 0x666666)
        leftTitle.font = UIFont.systemFont(ofSize: 15)
        self.addSubview(leftTitle)
        
        
        
        if cellType == twoCellType.editPW {
            leftTitle.snp.makeConstraints { (make) in
                make.left.equalTo(15)
                make.width.equalTo(70)
                make.centerY.equalTo(self.snp.centerY)
                make.height.equalTo(15)
            }
        }else{
            leftTitle.snp.makeConstraints { (make) in
                make.left.equalTo(15)
                make.width.equalTo(55)
                make.height.equalTo(15)
                make.centerY.equalTo(self.snp.centerY)
            }
          
        }
        
        inputTextField = UITextField()
        inputTextField.font = UIFont.systemFont(ofSize: 15)
        inputTextField.borderStyle = .none
        self.addSubview(inputTextField)
        inputTextField.snp.makeConstraints { (make) in
            make.left.equalTo(leftTitle.snp.right).offset(15)
            make.right.equalTo(-10)
            make.height.equalTo(45)
            make.centerY.equalTo(self.snp.centerY)
        }
        
        getVerifiButton = UIButton(type: .custom)
        getVerifiButton.setTitle("获取验证码", for: UIControlState())
        getVerifiButton.setTitleColor(UIColor(hex:0x999999), for: UIControlState())
        getVerifiButton.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        getVerifiButton.isHidden = true
        self.addSubview(getVerifiButton)
        getVerifiButton.snp.makeConstraints({ (make) in
            make.right.equalTo(-10)
            make.width.equalTo(80)
            make.top.bottom.equalTo(0)
        })
        
        getVerifiButton.addTarget(self, action: #selector(getVerifiAction), for: .touchUpInside)
        
        //cell上下两条线
        line1.frame = CGRect(x: 0, y: 0, width: AppConstant.screenWidth, height: 0.4)
        line1.backgroundColor = UIColor(hex: 0xdbdbdb)
        self.addSubview(line1)
        line2.backgroundColor = UIColor(hex: 0xdbdbdb)
        self.addSubview(line2)
        line2.snp.makeConstraints { (make) in
            make.left.equalTo(0)
            make.right.bottom.equalTo(0)
            make.height.equalTo(0.4)
        }
    }
    
    //收回键盘
    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        textField.resignFirstResponder()
        return true
    }
    
    func getVerifiAction(){
        delegate?.getVertifDelegate()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
